package org.omg.GIOP;

//
// Helper class for : IORAddressingInfo
//
// @author OpenORB Compiler
//
public class IORAddressingInfoHelper {

	//
	// Insert IORAddressingInfo into an any
	// @param a an any
	// @param t IORAddressingInfo value
	//
	public static void insert(org.omg.CORBA.Any a,
			org.omg.GIOP.IORAddressingInfo t) {
		a.insert_Streamable(new org.omg.GIOP.IORAddressingInfoHolder(t));
	}

	//
	// Extract IORAddressingInfo from an any
	// @param a an any
	// @return the extracted IORAddressingInfo value
	//
	public static org.omg.GIOP.IORAddressingInfo extract(org.omg.CORBA.Any a) {

		return read(a.create_input_stream());
	}

	//
	// Internal TypeCode value
	//
	private static org.omg.CORBA.TypeCode _tc = null;
	private static boolean _working = false;

	//
	// Return the IORAddressingInfo TypeCode
	// @return a TypeCode
	//
	public static org.omg.CORBA.TypeCode type() {
		if (_tc == null) {
			synchronized (org.omg.CORBA.TypeCode.class) {
				if (_tc != null)
					return _tc;
				if (_working)
					return org.omg.CORBA.ORB.init().create_recursive_tc(id());
				_working = true;
				org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
				org.omg.CORBA.StructMember[] _members = new org.omg.CORBA.StructMember[2];

				_members[0] = new org.omg.CORBA.StructMember();
				_members[0].name = "selected_profile_index";
				_members[0].type = orb
						.get_primitive_tc(org.omg.CORBA.TCKind.tk_ulong);
				_members[1] = new org.omg.CORBA.StructMember();
				_members[1].name = "ior";
				_members[1].type = org.omg.IOP.IORHelper.type();
				_tc = orb.create_struct_tc(id(), "IORAddressingInfo", _members);
				_working = false;
			}
		}
		return _tc;
	}

	//
	// Return the IORAddressingInfo IDL ID
	// @return an ID
	//
	public static String id() {
		return _id;
	}

	private final static String _id = "IDL:omg.org/GIOP/IORAddressingInfo:1.0";

	//
	// Read IORAddressingInfo from a marshalled stream
	// @param istream the input stream
	// @return the readed IORAddressingInfo value
	//
	public static org.omg.GIOP.IORAddressingInfo read(
			org.omg.CORBA.portable.InputStream istream) {
		org.omg.GIOP.IORAddressingInfo new_one = new org.omg.GIOP.IORAddressingInfo();

		new_one.selected_profile_index = istream.read_ulong();
		new_one.ior = org.omg.IOP.IORHelper.read(istream);

		return new_one;
	}

	//
	// Write IORAddressingInfo into a marshalled stream
	// @param ostream the output stream
	// @param value IORAddressingInfo value
	//
	public static void write(org.omg.CORBA.portable.OutputStream ostream,
			org.omg.GIOP.IORAddressingInfo value) {
		ostream.write_ulong(value.selected_profile_index);
		org.omg.IOP.IORHelper.write(ostream, value.ior);
	}

}
